package com.atguigu.spzx.product.controller;

import com.atguigu.spzx.model.entity.product.Category;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.atguigu.spzx.product.service.CategoryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName: CategoryController
 * Package: com.atguigu.spzx.product.controller
 * Description:
 *
 * @Author 刘强
 * @Create 2024/7/14 14:03
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/product/category")
//@CrossOrigin
public class CategoryController {
    @Resource
    private CategoryService categoryService;
    /**
     * 查询所有分类 -> 树形结构
     * @return
     */
    @GetMapping("findCategoryTree")
    public Result<List<Category>> findCategoryTree(){
        List<Category> list = categoryService.findCategoryTree();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }


}
